import $ from './jquery.js';
import { nav_item } from './nav-item.js';
import { banner } from './banner.js';
import { brandbody } from './brandbody.js';
import { topNav } from './fiextopnav.js';
import { lfList, lfListClick } from './lf-list.js';
// import { tabs } from './login.js';
window.onload = function() {
    //二级标题是否出现
    nav_item();
    //轮播图
    banner();
    //图片组合1
    brandbody();
    //顶部导航
    topNav();
    //左下导航
    lfList();
    lfListClick();
    //登录 选择方式
    // tabs();
    let username = location.search.split('=')[1];
    console.log(username);
    $.ajax({
        type: 'get',
        url: '../../interface/getItems.php',
        dateType: 'json'
    }).then(res => {
        let data = JSON.parse(res);
        console.log(JSON.parse(data[0].picture)[0].src);
        $('.middle-column-con').each((i, ele) => {
            $(ele).children('.one-grid-price').each((i, ele) => {
                $(ele).attr('href', './product.html?id=' + data[i].id);
            });
            $(ele).children('.one-grid-price').children().each((j, cur) => {
                $(cur).children('img').attr('src', JSON.parse(data[j].picture)[0].src.slice(0, -13) + '_430x430q90.jpg');
                $(cur).children('.floor-item-title').text(data[j].tiltle);
                $(cur).children('.floor-price').text('￥' + data[j].price);
            });
        })
    }).catch(xhr => {
        console.log(xhr.statue);
    })

}